package com.talent.model.convertor;

import com.talent.model.dto.SysMenuDto;
import com.talent.model.entity.sys.SysMenu;
import com.talent.model.vo.SysMenuVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface MenuConvertor {

    MenuConvertor INSTANCE = Mappers.getMapper( MenuConvertor.class );


    /**
     * 将dto转成po
     * @param dto
     * @return
     */

    @Mapping(target = "label",source = "label")
    @Mapping(target = "name",source = "name")
    @Mapping(target = "path",source = "path")
    @Mapping(target = "component",source = "component")
    SysMenu dtoToPo(SysMenuDto dto);

    /**
     * 将po转成vo
     * @param menu
     * @return
     */

    SysMenuVo poToVo(SysMenu menu);

    SysMenu update(SysMenuDto dto, @MappingTarget SysMenu menu);

    List<SysMenuVo> poListsToVoList(List<SysMenu> menus);
}
